import Mock from 'mockjs';

// 登录 post API
Mock.mock('/api/login','post',(options)=>{
   let {username,password}=JSON.parse(options.body);
   
   if(username==='admin' && password==="123"){
       return {
           code:0,
           message:"登陆成功",
           token:"admin"+new Date().getTime()
       }
   }else{
       return {
           code :1,
           message:"用户名或密码错误",
           token:""
       }
   }
})

// 产品列表
Mock.mock('/api/list',{
    code:0,
    data:Mock.mock({
        "服装|5-16":[
            {
                "key":"@id",
                "id|+1":1,
                 cate:"服装",
                "title":"@ctitle(4,15)",
                "image":"@image(100x100,@color,@city)",
                "price|1-5000":1,
                "stock|0-300":1,
                cartnum:0,
                checked:false      
            }
        ],
    
        "鞋子|5-16":[
            {
                "key":"@id",
                "id|+1":1,
                cate:"鞋子",
                "title":"@ctitle(4,15)",
                "image":"@image(100x100,@color,@city)",
                "price|1-5000":1,
                "stock|0-300":1,
                cartnum:0,
                checked:false      
            }
        ],
    
        "包包|5-16":[
            {
                "key":"@id",
                "id|+1":1,
                cate:"包包",
                "title":"@ctitle(4,15)",
                "image":"@image(100x100,@color,@city)",
                "price|1-5000":1,
                "stock|0-300":1,
                cartnum:0,
                checked:false      
            }
        ],
    
        "化妆品|5-16":[
            {
                "key":"@id",
                "id|+1":1,
                cate:"化妆品",
                "title":"@ctitle(4,15)",
                "image":"@image(100x100,@color,@city)",
                "price|1-5000":1,
                "stock|0-300":1,
                cartnum:0,
                checked:false      
            }
        ]
    })
}

);


// 菜品列表
const dish_data=Mock.mock({
    
  "list|10":[{
  id:"@id",
  title:"@ctitle(3,5)", // 分类
  "children|10-20":[{
      id:"@id",
      title:"@ctitle(4,10)",   // 名称
      "cate|1":["爆款直降","瓜果蔬菜","叶菜","调味菜","特价菜"],
      "price|1-100":1,
      image:"@image(100X100,@color,@city)"
  }]
}],
cate:["爆款直降","瓜果蔬菜","叶菜","调味菜","特价菜"]

})


Mock.mock('/api/dish',{
    code:0,
    data:dish_data
});